Database

Database(model_path, *, auto_open=True)

Represents a MIKE+ model database.

Attributes

Name Description
active_model Get the name of the active model.
active_scenario Name of the active scenario.
active_simulation Get the active simulation of the database.
db_path Get the path to the database file.
is_open Check if the database is open.
mupp_path Get the path to the MUPP file.
projection_string Get the projection string of the database.
scenarios Get the list of available scenarios.
srid Get the Spatial Reference ID (SRID) of the database.
tables A collection of tables in the database.
unit_system Get the unit system of the database in MIKE+ format.
version Get the version of the database.

Methods

Name Description
close Close the model database.
create Create a new MIKE+ model database.
open Open the model database.
run Run a simulation.

close

Database.close()

Close the model database.

create

Database.create(
    model_path,
    *,
    projection_string='',
    srid=-1,
    auto_open=True,
    overwrite=False,
)

Create a new MIKE+ model database.

Parameters

Name Type Description Default
model_path str or Path Path where the new database will be created required
projection_string str The projection string for the database ''
srid int The SRID for the database, e.g. 4326 for WGS84 -1
auto_open bool If True, immediately open the database connection True
overwrite (bool, optional(default is False)) If True, overwrite the existing database file if it exists False

Returns

Name Type Description
Database A Database object for the newly created database

Raises

Name Type Description
FileExistsError If the database already exists (except if overwrite is True)

open

Database.open()

Open the model database.

Returns

Name Type Description
self For method chaining

run

Database.run(simulation_muid=None, model_option=None)

Run a simulation.

Parameters

Name Type Description Default
simulation_muid str Simulation MUID. Defaults to the active simulation. None
model_option str | MUModelOption Model option. Defaults to active model if None. None

Examples

>>> with mp.open("path/to/model.sqlite") as db:
...     results = db.run()
>>> with mp.open("path/to/model.sqlite") as db:
...     results = db.run("My Simulation")
>>> db = mp.open("path/to/model.sqlite")
>>> results = db.run("My Simulation")
>>> db.close()

Returns

Name Type Description
list[Path] Paths to the result files.